❌Help me with my project ✅Help me write the introduction for a school project about climate change
Split complex tasks into simpler subtasks
❌Analyze a dataset and create a visualization ✅Subtask 1: Load and clean the data ✅Subtask 2: Perform statistical analysis ✅Subtask 3: Create appropriate visualizations ✅Subtask 4: Write up insights
Advantage, lower error rates compared to using a single query to perform the whole task.
Give the model time to think with chain of thought reasoning (i.e. step-by-step reasoning)
❓Problem: If it takes 6 workers 4 days to build a wall, how long would it take 8 workers? 💡As you solve this problem: ✅First, state what information is relevant ✅Then, explain how you’ll approach it ✅Show each calculation ✅Check if your answer makes sense ✅Explain why your answer is reasonable
Note, task decomposition can involve parallel processing, while chain of thought is typically sequential.
Role-based prompts
✅As a deep-sea biologist: A submersible has discovered massive die-offs of tube worms at 2000m depth near a hydrothermal vent that was previously thriving. What would be your initial assessment? ✅You’re a coastal oceanographer working with a beach community: Local swimmers report unusual purple-blue floating organisms appearing in large numbers during the past week. What’s your response?
Advantage, this helps give more specialized answers.
Provide references and/or examples
✅ Upload documents ✅ Provide text and/or code examples ✅ Even screenshots work well
Advantage, it reduces fake answers and match text and/or code style
Tell the model what to do, rather than what not to do
❌Don’t use complex technical terms when explaining photosynthesis ✅Explain photosynthesis using everyday language and familiar examples like sunlight helping plants make their food
Context matters - start a new chat if you change topics
💡 Remember the continuous text generation
Going deeper in prompt engineering 🔧
With Claude but similar rules apply to other models.
Prompt generator and/or improver
Original prompt 😑
From the following list of Wikipedia article titles, identify which article this sentence came from.
Respond with just the article title and nothing else.
Article titles:
{{titles}}
Sentence to classify:
{{sentence}}
Improved prompt 😍
You are an intelligent text classification system specialized in matching sentences to Wikipedia article titles. Your task is to identify which Wikipedia article a given sentence most likely belongs to, based on a provided list of article titles.
First, review the following list of Wikipedia article titles:
<article_titles>
{{titles}}
</article_titles>
Now, consider this sentence that needs to be classified:
<sentence_to_classify>
{{sentence}}
</sentence_to_classify>
Your goal is to determine which article title from the provided list best matches the given sentence. Follow these steps:
1. List the key concepts from the sentence
2. Compare each key concept with the article titles
3. Rank the top 3 most relevant titles and explain why they are relevant
4. Select the most appropriate article title that best encompasses or relates to the sentence's content
Wrap your analysis in <analysis> tags. Include the following:
- List of key concepts from the sentence
- Comparison of each key concept with the article titles
- Ranking of top 3 most relevant titles with explanations
- Your final choice and reasoning
After your analysis, provide your final answer: the single most appropriate Wikipedia article title from the list.
Output only the chosen article title, without any additional text or explanation.
use XML tags to help the assistant parse your prompts
XML tip
Use tags like <instructions>, <example>, and <formatting> to clearly separate different parts of your prompt. This prevents Claude from mixing up instructions with examples or context.
XML power use tip
Combine XML tags with other techniques like multishot prompting (<examples>) or chain of thought (<thinking>, <answer>). This creates super-structured, high-performance prompts.
XML in practice
You’re a financial analyst at AcmeCorp. Generate a Q2 financial report for our investors.
AcmeCorp is a B2B SaaS company. Our investors value transparency and actionable insights.
Use this data for your report:<data>{{SPREADSHEET_DATA}}</data>
<instructions>
1. Include sections: Revenue Growth, Profit Margins, Cash Flow.
2. Highlight strengths and areas for improvement.
</instructions>
Make your tone concise and professional. Follow this structure:
<formatting_example>{{Q1_REPORT}}</formatting_example>
Going back to role play prompting
<context>
You are an expert mechanical engineer with 15+ years of experience in automotive design and manufacturing processes. You have:
- Led design teams at major automotive companies
- Deep knowledge of materials science and structural mechanics
- Experience with both conventional and electric vehicle architectures
- Expertise in manufacturing optimization and quality control systems
</context>
<constraints>
- Always explain engineering concepts using precise technical terminology
- Support recommendations with relevant engineering principles
- Consider both theoretical and practical manufacturing limitations
- When discussing specifications, include relevant industry standards
- If unsure about specific details, acknowledge limitations and explain general principles
</constraints>
<tone>
Professional and technical, but able to explain complex concepts clearly to both experts and non-experts.
</tone>
Be proactive and keep on learning
📚 Prompt library 🎓 Anthropic courses 👀OpenAI and GitHub Copilot prompt engineering best practices 🔎 Practice makes you better
One more thing
Refrain from sharing everything in your prompts 😬
Personal or private information (e.g. full names, phone numbers, email addresses)
Sensitive information (e.g. financial information)
Private medical information
Copyrighted or trademarked material (e.g. subscription-only content, licensed software code)
Credentials (e.g. an API key, a password left in a code)
A quick prompt - not strictly following the best practices !
Build an app with Dynamic dataset selection between built-in R datasets such as<datasets>quakes, iris, faithful, airquality, mtcars, CO2, USArrests and women</datasets>Automatic UI updates based on selected dataMultiple visualization options:- Scatter plots with trend lines- Box plots- Violin plotsInteractive features:- Variable selection for both axes- Sample size control- Data preview table- Summary statistics